/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.contract.bean;

import com.yunhoo.sys.util.common.FacesUtils;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "contractInitBean")
@SessionScoped
public class ContractInitBean implements Serializable {

    private int type = 0;//0：主合同，1：补充合同
    private String url = "/page/contract/business/mainContract.xhtml";//默认主合同录入

    public void toggle() {
        if (type == -1) {
            url = "";
            return;
        }

        if (type == 0) {
            url = "/page/contract/business/mainContract.xhtml";
        } else if (type == 1) {
            url = "/page/contract/business/supplyContract.xhtml";
        }
    }

    public void addSupplyContract(String mainNumber) {
        type = 1;
        SupplyContractBean supplyContractBean = (SupplyContractBean) FacesUtils.getManagedBean("supplyContractBean");
        supplyContractBean.add();
        supplyContractBean.setMainNumber(mainNumber);
        toggle();
    }

    public void showSupplyContract(String supplyNumber) {
        type = 1;
        SupplyContractBean supplyContractBean = (SupplyContractBean) FacesUtils.getManagedBean("supplyContractBean");
        supplyContractBean.init(supplyNumber);
        toggle();
    }

    public void reSet() {
        type = -1;
        url = "";
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
